﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LCUI_BOOL
{
    public bool CurrentBool=false;
    public int BoolValue=0;
    //public static bool operator ==(LCUI_BOOL lhs, bool rhs)
    //{
    //    if (lhs.CurrentBool == rhs)
    //        return true;
    //    else
    //        return false;
    //}

    //public static bool operator !=(LCUI_BOOL lhs, bool rhs)
    //{
    //    if (lhs.CurrentBool != rhs)
    //        return true;
    //    else
    //        return false;
    //}

    public static bool operator ==(LCUI_BOOL lhs, System.Object rhs)
    {
        if (rhs == null)
        {
            if (System.Object.ReferenceEquals(lhs, null))
                return true;
            else
                return !lhs.CurrentBool;
        }
        else
        {
            if (System.Object.ReferenceEquals(lhs, null))
                return false;
            else
                return lhs.CurrentBool == ((LCUI_BOOL)rhs).CurrentBool;
        }
        //return System.Object.ReferenceEquals(lhs, rhs);
    }

    public static bool operator !=(LCUI_BOOL lhs, System.Object rhs)
    {
        if (rhs == null)
            if (System.Object.ReferenceEquals(lhs, null))
                return false;
            else
                return lhs.CurrentBool;
        else
        {
            if (System.Object.ReferenceEquals(lhs, null))
                return false;
            else
                return lhs.CurrentBool != ((LCUI_BOOL)rhs).CurrentBool;
        }
        //return !System.Object.ReferenceEquals(lhs, rhs);
    }

    public static bool operator !=(LCUI_BOOL lhs, int value)
    {
        return lhs.BoolValue != 0;
    }

    public static bool operator ==(LCUI_BOOL lhs, int value)
    {
        return lhs.BoolValue == 0;
    }

    public static implicit operator LCUI_BOOL(bool v)
    {
        LCUI_BOOL B = new LCUI_BOOL();
        B.CurrentBool = v;
        B.BoolValue = (v? 1 : 0);
        return B;
    }

    public static implicit operator bool(LCUI_BOOL mc)//隐式声明的class转bool类处理方法
    {
        if (System.Object.ReferenceEquals(mc, null))
        {
            //mc = false;
            return true;
        }
        return mc.CurrentBool;
    }
}
